package com.rui.cn.consumer.common;

import org.springframework.boot.autoconfigure.web.DefaultErrorAttributes;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestAttributes;

import java.util.Map;

/**
*@description：springboot自适应异常处理
*@author：[zhangruilin]
*@className：MyError
*@time：2018/5/17-15:50
**/
@Component
public class MyError  extends DefaultErrorAttributes {
    @Override
    public Map<String, Object> getErrorAttributes(RequestAttributes requestAttributes, boolean includeStackTrace) {
        Map<String, Object> map = super.getErrorAttributes(requestAttributes, includeStackTrace);
        map.put("company","atguigu");
        Map<String,Object> ext= (Map<String, Object>) requestAttributes.getAttribute("ext",0);
        map.put("ext", ext);
        return map;
    }

}